package com.wentao.mall.commons;

import com.wentao.mall.exception.MallException;
import com.wentao.mall.exception.MallExceptionEnum;

public enum OrderStatusEnum {
    CANCELED(0,"订单取消"),
    NOT_PAID(10,"未付款"),
    PAID(20,"已付款"),
    DELIVERED(30,"已发货"),
    FINISHED(40,"交易完成");

    private Integer statusCode;
    private String statusName;

    public Integer getStatusCode() {
        return statusCode;
    }

    public String getStatusName() {
        return statusName;
    }

    OrderStatusEnum(Integer statusCode, String statusName){
        this.statusCode=statusCode;
        this.statusName=statusName;
    }
    public static OrderStatusEnum codeOf(int code){
        for (OrderStatusEnum orderStatusEnum:values()){
            if (orderStatusEnum.getStatusCode()==code){
                return orderStatusEnum;
            }
        }
        throw new MallException(MallExceptionEnum.NO_ENUM);
    }
}
